from pprint import pprint

classes = [
    {"name": "abyss", "age": 25, "grade": "A"},
    {"name": "kin", "age": 23, "grade": "B"},
    {"name": "tian", "age": 24, "grade": "B"},
    {"name": "hun", "age": 26, "grade": "A"},
    {"name": "exe", "age": 21, "grade": "A"}
]
# 用匿名函数排序classes
classes1 = classes
classes.sort(key=lambda x: x["age"])
pprint(classes)

# 用常规函数排序classes
classes2 = classes


def classes_sort(x):
    return x["age"]


classes2.sort(key=classes_sort)
pprint(classes2)

# 用map函数将上述age+1


def foo_map(x):
    x["age"] += 1
    return x


pprint(list(map(foo_map, classes)))

# 用filter函数过滤garde是A的同学
classes3 = classes
classes4 = filter(lambda x: x["grade"] != "A", classes3)
pprint(list(classes4))


def foo(n):
    if n <= 1:
        return n
    else:
        return foo(n - 1) + foo(n - 2)


for i in range(10):
    print(foo(i), end=' ')
